package sample9;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.UnsupportedLookAndFeelException;

public class as {
	static JFrame frame = new JFrame();

	public static void main(String[] args) {

		LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();

		final Map<String, String> list = new HashMap();
		for (LookAndFeelInfo lookAndFeelInfo : lookAndFeelInfos) {
			list.put(lookAndFeelInfo.getName(), lookAndFeelInfo.getClassName());
			System.out.println(lookAndFeelInfo.getName());
		}

		final JComboBox comboBox = new JComboBox(list.keySet().toArray());

		comboBox.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				System.out.println(comboBox.getSelectedItem());
				changeLookAndFeel(list.get(comboBox.getSelectedItem()).toString());
			}

		});

		frame.setLayout(null);
		comboBox.setBounds(0, 0, 100, 25);
		frame.add(comboBox);

		frame.setSize(600, 400);
		frame.setVisible(true);
	}

	private static void changeLookAndFeel(String theLNFName) {
		try {
			UIManager.setLookAndFeel(theLNFName);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (UnsupportedLookAndFeelException e) {
			e.printStackTrace();
		}
		SwingUtilities.updateComponentTreeUI(frame);
	}
}
